var a = getApp(), util = require("../../../utils/util.js");

Page({
    data: {
        navbar: [ {
            name: "全部",
            id: ""
        } ],
        selectedindex: 0,
        mask1Hidden: !0,
        img: "http://img1.imgtn.bdimg.com/it/u=4078366710,4168441355&fm=200&gp=0.jpg",
        status: 1,
        pagenum: 1,
        order_list: [],
        storelist: [],
        mygd: !1,
        jzgd: !0,
        consume:0,
        page:1,
        pagesize:10,

    },
  consume_0: function () {
    var n = this;
    var store_id = wx.getStorageSync('sjdsjid');
    a.util.request({
      url: "entry/wxapp/newstoreorder",
      cachetime: "0",
      data: { store_id: store_id, status: 2 },
      success: function (t) {
        n.setData({
          order_list: t.data.data.list,
          consume: 0,
          page: 1
        });
      }
    });
  },
  consume_1: function () {
    var n = this;
    
    var store_id = wx.getStorageSync('sjdsjid');
    a.util.request({
      url: "entry/wxapp/newstoreorder",
      cachetime: "0",
      data: { store_id: store_id, status: 1 },
      success: function (t) {
        n.setData({
          order_list: t.data.data.list,
          consume: 1,
          page: 1
        });
      }
    });
  },
    onOverallTag: function(t) {
    },
    mask1Cancel: function() {
    },
    selectednavbar: function(t) {
    },
    reLoad: function() {
    },
    onLoad: function(t) {
      var n = this;
      var store_id = wx.getStorageSync('sjdsjid');
      a.setNavigationBarColor(this), a.sjdpageOnLoad(this)
      a.util.request({
        url: "entry/wxapp/newstoreorder",
        cachetime: "0",
        data: { store_id: store_id, status: 2 },
        success: function (t) {
          n.setData({
            order_list: t.data.data.list,
            consume: 0,
            page:1
          });
        }
      });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {
    },
    onPullDownRefresh: function() {
      // 显示顶部刷新图标
      wx.showNavigationBarLoading();
      var n = this;
      var store_id = wx.getStorageSync('sjdsjid');
      var consume = n.data.consume;
      var status;
      if (consume == 0){
        status = 2;
      }else{
        status = 1;
      }
      // a.setNavigationBarColor(this), a.sjdpageOnLoad(this)
      a.util.request({
        url: "entry/wxapp/newstoreorder",
        cachetime: "0",
        data: { store_id: store_id, status: status },
        success: function (t) {
          n.setData({
            order_list: t.data.data.list,
            page:1
          });
          // 隐藏导航栏加载框
          wx.hideNavigationBarLoading();
          // 停止下拉动作
          wx.stopPullDownRefresh();
        }
      });
    },
    onReachBottom: function() {
      var n = this;
      var store_id = wx.getStorageSync('sjdsjid');
      var page = n.data.page;
      page = page + 1;
      var consume = n.data.consume;
      var status;
      if (consume == 0) {
        status = 2;
      } else {
        status = 1;
      }
      // 显示加载图标
      wx.showLoading({
        title: '玩命加载中',
      })
      a.util.request({
        url: "entry/wxapp/newstoreorder",
        cachetime: "0",
        data: { store_id: store_id, status: status,page:page },
        success: function (t) {
          // 回调函数
          var order_list = n.data.order_list;

          for (var i = 0; i < t.data.data.list.length; i++) {
            order_list.push(t.data.data.list[i]);
          }
          // 设置数据
          n.setData({
            order_list: order_list,
            page:page
          })
          // 隐藏加载框
          wx.hideLoading();
        }
      });
    }
});